# try:
#     f = open("linux.txt", "r")
# except:
#     f = open("linux.txt", "w")

# try:
#     print(name)
# except NameError as e:
#     print("name变量名称未定义错误")


# try:
#     print(1 / 0)
# except (NameError, ZeroDivisionError):
#     print('ZeroDivision错误...')

# try:
#     print(num)
# except (NameError, ZeroDivisionError) as e:
#     print(e)

try:
    f = open("test.txt", "r", encoding="UTF-8")
except Exception as e:
    print("出现异常了")
    f = open("test.txt", "w", encoding="UTF-8")
else:
    print("没有异常，真开心！")
finally:
    print("有没有异常我都要执行！")
    f.close()
